package com.flute.framework.search.result;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.flute.tools.data.DataRecord;

//import com.flute.tools.util.StringUtil;

/**
 * 对lucene进行搜索时返回的结果 包括搜索时间，结果总数，拼写检查出的建议，文档信息列表
 * 
 * @author Dave
 * 
 */
public class SearchResult implements Serializable {
	private static final long serialVersionUID = -6302840984733400490L;
	private DataRecord propertyList;
	private List<ResultInfo> infoList;

	public SearchResult() {
		this.propertyList = new DataRecord();
		this.infoList = new ArrayList<ResultInfo>();
	}

	public void addProperty(String name, String value) {
		this.propertyList.AddField(name, value);
	}

	public String[] getAllProperties() {
		return propertyList.getAllFields();
	}

	public String getPropertyValue(String name) {
		// if (Constants.ResultFields.SPEND_TIME.equals(name)) {
		// return StringUtil
		// .getTimeString(propertyList.getFieldValue(name), 3);
		// }
		return propertyList.getFieldValue(name);
	}

	public void addSearchInfo(ResultInfo info) {
		this.infoList.add(info);
	}

	public List<ResultInfo> getInfoList() {
		return infoList;
	}

	public void setInfoList(List<ResultInfo> infoList) {
		this.infoList = infoList;
	}

	public void setPropertyList(DataRecord propertyList) {
		this.propertyList = propertyList;
	}

}
